package com.easy.modules.sysmgr.web.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.easy.common.util.Const;
import com.easy.common.web.BaseController;
import com.easy.common.web.page.Msg;
import com.easy.modules.sysmgr.service.AreaServiceI;
import com.easy.modules.sysmgr.web.form.AreaForm;

@Controller
@RequestMapping("/sysmgr/area")
public class AreaAction extends BaseController {
	
	@Autowired
	private AreaServiceI areaService ;
	
	@RequestMapping("/area_main.do")
	public String area_main() {
		return Const.SYSMGR + "area_main" ;
	}
	
	@RequestMapping("/area_form.do")
	public String area_form(AreaForm form, Model mode) {
		if(null != form.getId() && !"".equals(form.getId())) {
			mode.addAttribute("id", form.getId()) ;
		}
		return Const.SYSMGR + "area_form" ;
	}
	
	@RequestMapping("/get.do")
	@ResponseBody
	public AreaForm get(AreaForm form) {
		return this.areaService.get(form) ;
	}
	
	@RequestMapping("/add.do")
	@ResponseBody
	public Msg add(AreaForm form, HttpServletRequest request) {
		return this.areaService.add(form) ; 
	}
	
	@RequestMapping("/delete.do")
	@ResponseBody
	public Msg delete(AreaForm form, HttpServletRequest request) {
		Msg j = this.areaService.delete(form) ;
		return j ; 
	}
	
	@RequestMapping("/edit.do")
	@ResponseBody
	public Msg edit(AreaForm form) {
		return this.areaService.edit(form) ; 
	}
	
	@RequestMapping("/treegrid_areas.do")
	@ResponseBody
	public List<AreaForm> treegrid_areas(AreaForm form) {
		return this.areaService.findAreas(form) ;
	}
	
}
